package demoMod.stsconsole.powers;

import demoMod.stsconsole.core.AbstractCreature;
import demoMod.stsconsole.interfaces.PowerApplySubscriber;

public class ArtifactPower extends AbstractPower implements PowerApplySubscriber {
    public static final String ID = "ArtifactPower";

    public ArtifactPower(AbstractCreature owner, int amount) {
        super(ID, owner, amount);
    }

    @Override
    public String getUpdatedDescriptions() {
        return String.format(this.description, this.amount[0]);
    }

    @Override
    public boolean onPowerApply(AbstractPower powerToApply, AbstractCreature target) {
        if (powerToApply.type == PowerType.DEBUFF && target == this.owner) {
            this.amount[0]--;
        }
        if (this.amount[0] <= 0) {
            this.onRemove();
        }
        return powerToApply.type == PowerType.BUFF || target != this.owner;
    }
}
